<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上传</title>
</head>

<body>
    <input type="file" id="file" style="display:none;">
    <img src="https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3416813967,3014974917&fm=26&gp=0.jpg" alt=""
        onclick="fileImg()" style="cursor: pointer;width:120px;">
    <script>
        var file = document.getElementById('file');

        function fileImg() {
            file.click();
        }
        file.onchange = function (e) {
            const formData = new FormData();
            formData.append('avatar', e.target.files[0]);
            axios.post('/api/v1/f/upload_file', formData, {
                headers: {
                    'Content-Type': 'multipart/form-data',
                }
            }).then(res => {
                console.log(res.data);
            });
        }
    </script>
</body>

</html>